//
//  HomeSearchHotKeyWordView.swift
//  HomeSearchHotKeyWordView
//
//  Created by Ben on 2021/8/18.
//

import SwiftUI

struct SerachHotKey: Codable {
    var title: String
}

struct HomeSearchHotKeyWordView: View {
    

    private let ITEM_HEIGHT: CGFloat = 40
    
    private let hotKeywords: [SerachHotKey] = [
        SerachHotKey(title: "春风250"),
        SerachHotKey(title: "MacBook Pro 15"),
        SerachHotKey(title: "iPhone 13"),
        SerachHotKey(title: "佳能相机"),
        SerachHotKey(title: "哈佛H6"),

    ]
//    ["春风250", "MacBook Pro 15", "iPhone 13", "佳能相机", "哈佛H6"]
        
    private var loopHotKeywords: [SerachHotKey] {
        return [hotKeywords.last!] + hotKeywords + [hotKeywords.first!]
    }
    
    
    var body: some View {
        

        CycleScrollView(scrollDirection: .vertical, showsIndicators: false, dataSource: loopHotKeywords, itemLength: ITEM_HEIGHT) { data in
            Text(data.title)
                .foregroundColor(Color.black.opacity(0.4))
                .font(.system(size: 14, weight: .bold))
        }
    }
}

struct HomeSearchHotKeyWordView_Previews: PreviewProvider {
    static var previews: some View {
        HomeSearchHotKeyWordView()
    }
}
